package timingAttack;

import java.io.IOException;
import java.net.ServerSocket;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Server implements Runnable{
	public static final int PORT = 4000;
	public static byte[] digest;
	public Server(){
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		String message = "Test";
		
		md.update(message.getBytes(),0,message.length());
		digest = md.digest();
		
	}
	
	public void run(){
		ServerSocket provider = null;
		try{
			provider = new ServerSocket(PORT);
			
			while(true){
				Thread handler = new Thread(new ServerHandler(provider.accept()));
				System.out.println("Abdul is connected.");
				handler.start();
			}
		}
		catch(IOException e){
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[]args){
		Thread server = new Thread(new Server());
		server.start();
	}
	
}
